// 自定义hook
import { useState } from "react";

function useMyHook (initValue) {
  const [count, setCount] = useState(initValue);
  function add () {
    setCount(count + 1);
  }
  function minus () {
    setCount(count - 1);
  }
  return [count, add, minus];
} 
function App() {
  const [count, add, minus] = useMyHook(0);
  return (
    <div>
      <h1>{count}</h1>
      <button onClick={minus}>-</button>
      <button onClick={add}>+</button>
    </div>
  )
}
export default App; 